package service

import (
	"context"
	"jk-time/webook/follow/domain"
	"jk-time/webook/follow/repository"
)

type FollowService interface {
	GetFollowee(ctx context.Context, follower, offset, limit int64) ([]domain.FollowRelation, error)
	// FollowInfo 查看关注人的详情
	FollowInfo(ctx context.Context, follower int64, followee int64) (domain.FollowRelation, error)
	// AddFollowRelation 创建关注关系
	AddFollowRelation(ctx context.Context, follower int64, followee int64) error
	// InactiveFollowRelation 取消关注
	InactiveFollowRelation(ctx context.Context, follower int64, followee int64) error
	GetFollowStatics(ctx context.Context, uid int64) (domain.FollowStatics, error)
}
type followService struct {
	repo repository.FollowRepository
}

func (f followService) GetFollowee(ctx context.Context, follower, offset, limit int64) ([]domain.FollowRelation, error) {
	return f.repo.GetFollowee(ctx, follower, offset, limit)
}

func (f followService) FollowInfo(ctx context.Context, follower int64, followee int64) (domain.FollowRelation, error) {
	return f.repo.FollowInfo(ctx, follower, followee)
}

func (f followService) AddFollowRelation(ctx context.Context, follower, followee int64) error {
	return f.repo.AddFollowRelation(ctx, domain.FollowRelation{
		Followee: followee,
		Follower: follower,
	})
}

func (f followService) InactiveFollowRelation(ctx context.Context, follower int64, followee int64) error {
	return f.repo.InactiveFollowRelation(ctx, follower, followee)
}

func (f followService) GetFollowStatics(ctx context.Context, uid int64) (domain.FollowStatics, error) {
	return f.repo.GetFollowStatics(ctx, uid)
}

func NewFollowService(repo repository.FollowRepository) FollowService {
	return &followService{repo: repo}
}
